/**
 * 
 */
package com.py.credit.entity.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.py.credit.entity.common.OptionalColumn;

/**
 * @author dd
 *
 */
public enum ResourceContentPublishTableFieldEnum {

	NAME("name", "版本名称", "varchar", "input", true, true, new HashMap<String, String>(), true, true), 
	TABLE_NUM("table_num", "信息资源", "number", "input", true, false, new HashMap<String, String>(), false,false),
	COL_NUM("col_num", "数据项", "number", "input", true, false, new HashMap<String, String>(), false,false),
	DESCRIPTION("description", "摘要", "varchar", "input", true, true,new HashMap<String, String>(), true, true),
	MAINTAINER("maintainer", "维护人", "varchar","input", true, true, new HashMap<String, String>(), true,true), 
	UPDATE_TIME("update_time", "维护时间", "timestamp", "input", true, false,new HashMap<String, String>(), true, false),
	CHECK_STATUS("check_status", "审核状态", "varchar", "select",true, false, new HashMap<String, String>(){
		private static final long serialVersionUID = 1L;
	   { 
		   put("W", "登记状态");
		   put("S", "审核中");
		   put("P", "审核通过");
		   put("R", "审核不通过");
		
	    }
	}, true,false),
	STATUS("status", "版本状态", "varchar", "select", true,false, new HashMap<String, String>(){
		private static final long serialVersionUID = 1L;
	{
		put("Y", "启用");
		put("N", "未启用");
	}
	
	}, true, false);

	private String colNameEN;
	private String colNameCN;
	private String type;
	private boolean defaultShow;
	private String widget;
	private boolean fuzzy;
	private HashMap<String, String> widgetValue;
	private boolean searchIsShow;
	private boolean advanceConditionShow;

	private ResourceContentPublishTableFieldEnum(String colNameEN, String colNameCN, String type, String widget,
			boolean defaultShow, boolean fuzzy, HashMap<String, String> widgetValue, boolean advanceConditionShow,
			boolean searchIsShow) {
		this.colNameEN = colNameEN;
		this.colNameCN = colNameCN;
		this.type = type;
		this.widget = widget;
		this.defaultShow = defaultShow;
		this.fuzzy = fuzzy;
		this.widgetValue = widgetValue;
		this.searchIsShow = searchIsShow;
		this.advanceConditionShow = advanceConditionShow;
	}

	public boolean isAdvanceConditionShow() {
		return advanceConditionShow;
	}

	public void setAdvanceConditionShow(boolean advanceConditionShow) {
		this.advanceConditionShow = advanceConditionShow;
	}

	public String getColNameEN() {
		return colNameEN;
	}

	public void setColNameEN(String colNameEN) {
		this.colNameEN = colNameEN;
	}

	public String getColNameCN() {
		return colNameCN;
	}

	public void setColNameCN(String colNameCN) {
		this.colNameCN = colNameCN;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public boolean isDefaultShow() {
		return defaultShow;
	}

	public void setDefaultShow(boolean defaultShow) {
		this.defaultShow = defaultShow;
	}

	public String getWidget() {
		return widget;
	}

	public void setWidget(String widget) {
		this.widget = widget;
	}

	public boolean isFuzzy() {
		return fuzzy;
	}

	public void setFuzzy(boolean fuzzy) {
		this.fuzzy = fuzzy;
	}

	public HashMap<String, String> getWidgetValue() {
		return widgetValue;
	}

	public void setWidgetValue(HashMap<String, String> widgetValue) {
		this.widgetValue = widgetValue;
	}

	public boolean isSearchIsShow() {
		return searchIsShow;
	}

	public void setSearchIsShow(boolean searchIsShow) {
		this.searchIsShow = searchIsShow;
	}

	public static List<OptionalColumn> getOptionalColumns() {

		List<OptionalColumn> OptionalColumns = new ArrayList<OptionalColumn>();

		ResourceContentPublishTableFieldEnum[] values = ResourceContentPublishTableFieldEnum.values();

		for (ResourceContentPublishTableFieldEnum value : values) {

			OptionalColumn optionalColumn = new OptionalColumn(value.getColNameEN(), value.getColNameCN(),
					value.getType(), value.isDefaultShow(), value.getWidget(), value.isFuzzy(), value.getWidgetValue(),
					value.isSearchIsShow());
			OptionalColumns.add(optionalColumn);

		}
		return OptionalColumns;

	}

	public static List<String> getDefaultShowColumnEN() {

		List<String> columns = new ArrayList<String>();

		ResourceContentPublishTableFieldEnum[] values = ResourceContentPublishTableFieldEnum.values();

		for (ResourceContentPublishTableFieldEnum value : values) {

			if (value.isDefaultShow()) {

				columns.add(value.getColNameEN());

			}

		}
		return columns;

	}

	public static List<OptionalColumn> getAdvancedConditionColumns() {
		List<OptionalColumn> OptionalColumns = new ArrayList<OptionalColumn>();

		ResourceContentPublishTableFieldEnum[] values = ResourceContentPublishTableFieldEnum.values();

		for (ResourceContentPublishTableFieldEnum value : values) {

			if (value.isAdvanceConditionShow()) {

				OptionalColumn optionalColumn = new OptionalColumn(value.getColNameEN(), value.getColNameCN(),
						value.getType(), value.isDefaultShow(), value.getWidget(), value.isFuzzy(),
						value.getWidgetValue(), value.isSearchIsShow());
				OptionalColumns.add(optionalColumn);
			}

		}
		return OptionalColumns;
	}

}
